<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>城市代理商管理-添加城市代理商</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="添加城市代理商"/>
    <meta name="keywords" content=""/>
    <meta name="author" content="wangl"/>
    <link rel="icon" href="http://ow9lg82yy.bkt.clouddn.com/24f5c360-485d-4a6d-9468-2a61c353cf37.ico">
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/static/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <style type="text/css">
        .layui-form-item .layui-inline {
            width: 33.333%;
            float: left;
            margin-right: 0;
        }

        @media (max-width: 1240px) {
            .layui-form-item .layui-inline {
                width: 100%;
                float: none;
            }
        }

        .layui-form-item .role-box {
            position: relative;
        }

        .layui-form-item .role-box .jq-role-inline {
            height: 100%;
            overflow: auto;
        }

        /***
        *  ztree 图标变成黄色
        */
        .ztree .line {
            line-height: 0;
            border-top: none;
            float: none;
        }

        .ztree li span.button.ico_docu {
            background-position: -110px 0;
            margin-right: 2px;
            vertical-align: top;
        }

        .multiSelect {
            line-height: normal;
            height: auto;
            padding: 4px 10px;
            overflow: hidden;
            min-height: 38px;
            margin-top: -38px;
            left: 0;
            z-index: 99;
            position: relative;
            background: none;
        }

        .multiSelect a {
            padding: 2px 5px;
            background: #908e8e;
            border-radius: 2px;
            color: #fff;
            display: block;
            line-height: 20px;
            height: 20px;
            margin: 2px 5px 2px 0;
            float: left;
        }

        .multiSelect a span {
            float: left;
        }

        .multiSelect a i {
            float: left;
            display: block;
            margin: 2px 0 0 2px;
            border-radius: 2px;
            width: 8px;
            height: 8px;
            background: url(/static/images/close.png) no-repeat center;
            background-size: 65%;
            padding: 4px;
        }

        .multiSelect a i:hover {
            background-color: #545556;
        }

        .layui-field-box a {
            padding: 2px 5px;
            background: #908e8e;
            border-radius: 2px;
            color: #fff;
            display: block;
            line-height: 20px;
            height: 20px;
            margin: 2px 5px 22px 0;
            float: left;
        }

        .layui-field-box a span {
            float: left;
        }

        .boxadd {
            float: left;
            display: block;
            margin: 2px 0 0 2px;
            border-radius: 2px;
            width: 8px;
            height: 8px;
            background-size: 65%;
            padding: 4px;
        }
    </style>
</head>
<body class="childrenBody">
<form class="layui-form" action="/back/shareholder/agent/add" method="POST"
 style="width:80%;">
    <input type="hidden" id="id" name="id" />
<div class="layui-form-item">
    <label class="layui-form-label">城市代理商昵称</label>
    <div class="layui-input-block">
        <input type="text" class="layui-input" id="nickName" name="nickName" placeholder="请输入城市代理商昵称">
    </div>
</div>
<div class="layui-form-item">
    <label class="layui-form-label">手机号</label>
    <div class="layui-input-block">

        <input type="text" class="layui-input" id="tel" name="tel" placeholder="请输入手机号">
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">所在区域</label>
    <#--<div class="layui-input-block">-->
        <#--<input type="text" class="layui-input" id="openBank" name="openBank" placeholder="请输入开户银行">-->
    <#--</div>-->
        <div class="layui-col-md3">
            <label class="layui-form-label">请选择省:</label>
            <div class="layui-input-block">
                <select name="province" id="province" lay-filter="province">

                </select>
            </div>
        </div>
        <div class="layui-col-md3">
            <label class="layui-form-label">请选择市:</label>
            <div class="layui-input-block">
                <select name="city" id="city" lay-filter="city">

                </select>
            </div>
        </div>
        <div class="layui-col-md3">
            <label class="layui-form-label">请选择县/区:</label>
            <div class="layui-input-block">
                <select name="district" id="district">
                </select>
            </div>
        </div>
</div>
    <div class="layui-form-item">
        <label class="layui-form-label">登录密码</label>
        <div class="layui-input-block">

            <input type="text" class="layui-input" id="password" name="password" placeholder="请输入登录密码">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">佣金比例</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="commRate" name="commRate" >
        </div>
    </div>



<div class="layui-form-item">
    <div class="layui-input-block">
        <button class="layui-btn" lay-submit="" lay-filter="addPartner">立即提交</button>
        <#--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
    </div>
</div>
</form>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/layui/layui.js"></script>
<#--<script type="text/javascript" src="/static/layui/city/data.js"></script>-->
<#--<script type="text/javascript" src="/static/layui/city/get.js"></script>-->
<script type="text/javascript" src="/static/js/wangEditor.min.js"></script>
<script type="text/javascript" src="/static/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<script>

    layui.use(['form', 'jquery', 'layer', 'upload', 'laydate'], function () {
        var form = layui.form,
                $ = layui.jquery,
                upload = layui.upload,
                E = window.wangEditor,
                laydate = layui.laydate,
                imageIndex,
                layer = layui.layer,
                zTreeObj,
                setting = {
                    callback: {
                        onClick: function (event, treeId, treeNode) {
                            $("#channelNameShow").val(treeNode.name);
                            $("input[name='channelId']").val(treeNode.id);
                        }
                    }
                };
                // zTreeObj = /*$.fn.zTree($("#treeDemo"), setting,)*/1;
        //普通图片上传
        var anPicture = upload.render({
            elem: '#anPicture',
            url: '/file/upload/',
            field: 'test',
            before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#anPicture').attr('src', result); //图片链接（base64）
                });
                imageIndex = layer.load(2, {
                    shade: [0.3, '#333']
                });
            },
            done: function (res) {
                layer.close(imageIndex);
                //如果上传失败
                if (res.success === false) {
                    return layer.msg('上传失败');
                }
                $("#showPic").val(res.data.url);
            },
            error: function () {
                layer.close(imageIndex);
                //演示失败状态，并实现重传
                var demoText = $('#demoText_showPic');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    anPicture.upload();
                });
            }
        });

        //初始赋值
        laydate.render({
            elem: '#publistTime',
            value: new Date()
        });
        var content_editor = new E('#content');
        //图片上传
        content_editor.customConfig.uploadImgServer = '/file/uploadWang';
        content_editor.customConfig.uploadFileName = 'test';
        // 自定义处理粘贴的文本内容(这里处理图片抓取)
        content_editor.customConfig.pasteTextHandle = function (content) {
            if (undefined === content) {
                return content;
            }
            if (content.indexOf("src=") <= 0) {
                return content;
            }
            var loadContent = layer.load(2, {
                shade: [0.3, '#333']
            });
            $.ajax({
                url: "/file/doContent/",
                type: "POST",
                async: false,
                data: {"content": content},
                dataType: "json",
                success: function (res) {
                    layer.close(loadContent);
                    content = res.data;
                }
            });
            return content;
        };
        // 关闭粘贴样式的过滤
        content_editor.customConfig.pasteFilterStyle = false;
        content_editor.customConfig.customAlert = function (info) {
            // info 是需要提示的内容
            console.log("info:" + info);
            layer.msg(info);
        };
        var anContentInput = $("#anContent");
        content_editor.customConfig.onchange = function (html) {
            // html 即编辑器中的内容
            console.log("123"+html);
            anContentInput.val(html);
        };
        content_editor.create();

        var id = getParam("id");

        function getPartner(id) {
            var partner;
            $.ajax({
                async: false,
                url: '/back/shareholder/partner/edit?userId=' + id + '',
                type: 'get',
                success: function (baseDto) {
                    dealBaseDto(baseDto, function (baseDto) {
                        partner = baseDto.data;
                    })

                }
            });
            return partner;
        }

        // var partner = getPartner(id);
        // function loadData(partner) {
        //     // //设置创建时间
        //     // var newCreateTimeInput = $("#createTime");
        //     // newCreateTimeInput.val(news.createTime);
        //     // //设置更新时间
        //     // var newUpdateTimeInput = $("#updateTime");
        //     // newUpdateTimeInput.val(news.updateTime);
        //     //设置id
        //     var partnerIdInput = $("#id");
        //     partnerIdInput.val(partner.id);
        //     //设置姓名
        //     var partnerNickNameInput = $("#nickName");
        //     partnerNickNameInput.val(partner.nickName);
        //     //设置手机号
        //     var partnerTelInput = $("#tel");
        //     partnerTelInput.val(partner.tel);
        // }

        // loadData(partner);

        layui.use('form', function () {
            var form = layui.form;
            //监听提交
            form.on('submit(*)', function (data) {
                window.location.href = '/back/agent/listpage';
            });
            $.ajax({
                async: false,
                url: '/area/province',
                type: 'get',
                success: function (baseDto) {
                    var data = baseDto.data
                    addSelect('province',data,true,'areaCode','areaName');
                }
            });

            // 一级联动事件触发
            form.on('select(province)', function(data){
                var value = data.value;
                $.ajax({
                    async: false,
                    url: '/area/city?provinceId='+ value,
                    type: 'get',
                    success: function (baseDto) {
                        var data = baseDto.data
                        addSelect('city',data,true,'areaCode','areaName');
                    }
                });
                // areaState.area.fn(value);
            });

            // 二级联动事件触发
            form.on('select(city)', function(data){
                var value = data.value;
                $.ajax({
                    async: false,
                    url: '/area/district?cityId='+ value,
                    type: 'get',
                    success: function (baseDto) {
                        var data = baseDto.data
                        addSelect('district',data,true,'areaCode','areaName');
                    }
                });
            });

            //select添加选项
            function addSelect(id,data,bool,val,text,region){
                //bool是否添加“请选择”选项
                val = val || 'type';
                text = text || 'name';
                var d="'"+region+"'";
                var html = '';
                var $id = $('#'+id);
                $id.html('');
                if(bool){html += '<option value="">请选择</option>';}
                for(var i in data){
                    html +='<option value="'+data[i][val]+'">'+data[i][text]+'</option>';
                }
                $id.html(html);
                form.render("select");
            }
        });

        // addSelect('quiz1',selDate.area,true,'regionCode','regionName');
    });

</script>
</body>
</html>